package com.yuandian.bpm.bi.modules.user.service.impl;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuandian.bpm.bi.modules.user.entity.ConfAddresseeApp;
import com.yuandian.bpm.bi.modules.user.entity.ConfAddresser;
import com.yuandian.bpm.bi.modules.user.mapper.ConfAddresserMapper;
import com.yuandian.bpm.bi.modules.user.service.ConfAddresserService;
import com.yuandian.bpm.bi.modules.user.vo.ConfAddresserVo;
import com.yuandian.bpm.common.core.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
*
*/
@Service
public class ConfAddresserServiceImpl extends ServiceImpl<ConfAddresserMapper, ConfAddresser> implements ConfAddresserService {

	@Autowired
	private ConfAddresserMapper confAddresserMapper;
	/**
	 * 分页查询
	 *
	 * @param confAddresserVo 筛选条件
	 * @return 通用返回对象
	 */
	@Override
	public Page<ConfAddresseeApp> listPage(ConfAddresserVo confAddresserVo) {
		return confAddresserMapper.listPage(new Page<>(confAddresserVo.getPageNum(), confAddresserVo.getPageSize()), confAddresserVo);
	}

	/**
	 * 新增数据
	 *
	 * @param confAddresser 实例对象
	 * @return 通用返回对象
	 */
	@Override
	public R<String> saveData(ConfAddresser confAddresser) {
		confAddresserMapper.saveData(confAddresser);
		return R.ok();
	}

	/**
	 * 通过主键更新数据
	 *
	 * @param confAddresser 实例对象
	 * @return 通用返回对象
	 */
	@Override
	public R<String> updateDataById(ConfAddresser confAddresser) {
		confAddresserMapper.updateDataById(confAddresser);
		return R.ok();
	}

	/**
	 * 默认发件人
	 *
	 * @param id 主键
	 * @return 通用返回对象
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public R<String> defaultSender(Integer id) {
		confAddresserMapper.defaultSender(null, 0);
		confAddresserMapper.defaultSender(id, 1);
		return R.ok();
	}
}
